#!/usr/bin/env python
# From http://michael.susens-schurter.com/blog/2008/10/30/listing-all-passwords-stored-in-gnome-keyring/

import pygtk
pygtk.require('2.0')
import gtk # sets app name
import gnomekeyring
import pickle
 
def hack():
    keyring = "balancer.credentials"
    for id in gnomekeyring.list_item_ids_sync(keyring):
        item = gnomekeyring.item_get_info_sync(keyring, id)
        #print dir(item)
        print '[%s] %s = %s' % (
                keyring, item.get_display_name(), pickle.loads(item.get_secret()))
        attr = gnomekeyring.item_get_attributes_sync(keyring, id)
        for k in attr:
            print "\t%s = %s" % (k, attr[k])
    else:
        if len(gnomekeyring.list_item_ids_sync(keyring)) == 0:
            print '[%s] --empty--' % keyring
 
if __name__ == '__main__':
    hack()
